<?php
class Lances_Pagamentos_M extends I_Model {

    protected $_table_name = 'lances_pagamentos';
    protected $_primary_key = 'PAGAMENTO_ID';
    protected $_primary_filter = 'intval';
    protected $_order_by = 'PAGAMENTO_ID';
    protected $_direction = 'DESC';
    public $rules = array();
    protected $_timestamps = FALSE;

    public function __construct() {
        parent::__construct();
    }

  
    function all($id){
        
        $this->db->select('lt.DESCRICAO,lt.NUM_LOTE,le.DATA AS LEILAO_DATA,cm.RAZAO,cm.EMAIL AS C_EMAIL,cm.REPRESENTANTE,cm.TELEFONE AS C_TELEFONE,lc.TOTAL,lc.COMISSAO,lc.TOTAL_COMISSAO,pf.*,pg.*')
                 ->from('lances_pagamentos as pg')
                 ->join('lances_arrematados as lca','pg.PAGAMENTO_ID=lca.PAGAMENTO_ID')
                 ->join('lances as lc','lc.ID=lca.LANCE_ID')
                 ->join('leiloes as le','le.ID=pg.LEILAO_ID')
                 ->join('comitentes as cm','cm.ID=le.COMITENTE_ID')
                 ->join('lotes as lt','lt.ID=pg.LOTE_ID')
                ->join('users as usr','usr.ID=pg.USER_ID')
                ->join('profiles as pf','pf.USER_ID=usr.ID')
                ->where(array('pg.PAGAMENTO_ID'=>$id))
                ;
        
        $q = $this->db->get();
        
        return $q->row();
        
    }
    
}